/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package draftMate.ui;

import draftMate.*;
import draftMate.player.*;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author brianjob
 */
public class DraftMateUI extends javax.swing.JFrame {

    /**
     * class to detect the team selected and update the teamSelected
     * member accordingly
     */
    private class TeamSelectionHandler implements ListSelectionListener {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel lsm = (ListSelectionModel)e.getSource();
            if (lsm.isSelectionEmpty()) {
                tht.setTeam(null);
                tpt.setTeam(null);
                tht.fireTableDataChanged();
                tpt.fireTableDataChanged();
            } else {
                int min = lsm.getMinSelectionIndex();
                int max = lsm.getMaxSelectionIndex();
                for (int i = min; i <= max; i++) {
                    if (lsm.isSelectedIndex(i)) {
                        int selTeam = teamTable.convertRowIndexToModel(i);
                        tht.setTeam(draft.getTeam(selTeam));
                        tpt.setTeam(draft.getTeam(selTeam));
                        tht.fireTableDataChanged();
                        tpt.fireTableDataChanged();
                    }
                }
            }
        }
    }
    
    private DraftMate draft;
    private HitterTable ht;
    private PitcherTable pt;
    private TeamTable tt;
    private TeamHitterTable tht;
    private TeamPitcherTable tpt;
    private ListSelectionModel ttSelectionModel;
    private DefaultListModel addTeamsListModel;
    private TableRowSorter hitterSorter;
    
    private boolean c;
    private boolean fb;
    private boolean sb;
    private boolean tb;
    private boolean ss;
    private boolean of;

    /**
     * Creates new form DraftMateUI
     */
    public DraftMateUI() {
        draft = new DraftMate();
        ht = new HitterTable(draft);
        pt = new PitcherTable(draft);
        tt  = new TeamTable(draft);
        tht = new TeamHitterTable();
        tpt = new TeamPitcherTable();
        hitterSorter = new TableRowSorter<HitterTable>(ht);
        c = sb = tb = ss = of = fb = true;
        newFilter();
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDialogNewTeam = new javax.swing.JDialog();
        addTeamField = new javax.swing.JTextField();
        jButtonAddTeam = new javax.swing.JButton();
        fcs = new javax.swing.JFileChooser();
        fcs.setDialogTitle("Save");
        fcs.setMultiSelectionEnabled(false);
        fcs.setApproveButtonText("Save");
        fco = new javax.swing.JFileChooser();
        fcNew = new javax.swing.JFileChooser();
        newDraftDialog = new JDialog(DraftMateUI.this);
        jLabel8 = new javax.swing.JLabel();
        pitchText = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        secondText = new javax.swing.JTextField();
        catchText = new javax.swing.JTextField();
        firstText = new javax.swing.JTextField();
        pitchBrowse = new javax.swing.JButton();
        ofText = new javax.swing.JTextField();
        shortText = new javax.swing.JTextField();
        thirdText = new javax.swing.JTextField();
        createNewDraftButton = new javax.swing.JButton();
        cancelNewDraftButton = new javax.swing.JButton();
        addTeamNewDraftButton = new javax.swing.JButton();
        removeTeamNewDraftButton = new javax.swing.JButton();
        ofBrowse = new javax.swing.JButton();
        ssBrowse = new javax.swing.JButton();
        firstBrowse = new javax.swing.JButton();
        catchBrowse = new javax.swing.JButton();
        thirdBrowse = new javax.swing.JButton();
        secondBrowse = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        addTeamsListModel = new DefaultListModel();
        addTeamsList = new javax.swing.JList();
        jLabel9 = new javax.swing.JLabel();
        addTeamText = new javax.swing.JTextField();
        jSplitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jPanel2, jPanel1);
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        hitterTable = new javax.swing.JTable();
        hitterTable.setRowSorter(hitterSorter);
        jScrollPane2 = new javax.swing.JScrollPane();
        pitcherTable = new javax.swing.JTable();
        pitcherTable.setAutoCreateRowSorter(true);
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        cBoxC = new javax.swing.JCheckBox();
        cBox1 = new javax.swing.JCheckBox();
        cBox2 = new javax.swing.JCheckBox();
        cBox3 = new javax.swing.JCheckBox();
        cBoxS = new javax.swing.JCheckBox();
        cBoxOF = new javax.swing.JCheckBox();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        teamTable = new javax.swing.JTable();
        teamTable.setAutoCreateRowSorter(true);
        ttSelectionModel = teamTable.getSelectionModel();
        ttSelectionModel.addListSelectionListener(
            new TeamSelectionHandler());
        teamTable.setSelectionModel(ttSelectionModel);
        jScrollPane4 = new javax.swing.JScrollPane();
        teamHitterTable = new javax.swing.JTable();
        teamHitterTable.setAutoCreateRowSorter(true);
        jScrollPane5 = new javax.swing.JScrollPane();
        teamPitcherTable = new javax.swing.JTable();
        draftPitcherButton = new javax.swing.JButton();
        draftHitterButton = new javax.swing.JButton();
        undraftHitterButton = new javax.swing.JButton();
        undraftPitcherButton = new javax.swing.JButton();
        addTeamButton = new javax.swing.JButton();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu2 = new javax.swing.JMenu();
        newDraftMI = new javax.swing.JMenuItem();
        newTeamMI = new javax.swing.JMenuItem();
        openMI = new javax.swing.JMenuItem();
        saveMI = new javax.swing.JMenuItem();
        exitMI = new javax.swing.JMenuItem();

        jDialogNewTeam.setTitle("Add Team");
        jDialogNewTeam.setAlwaysOnTop(true);
        jDialogNewTeam.setMinimumSize(new java.awt.Dimension(404, 78));
        jDialogNewTeam.setResizable(false);

        addTeamField.setText("Team Name");

        jButtonAddTeam.setText("Add Team");
        jButtonAddTeam.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAddTeamActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jDialogNewTeamLayout = new javax.swing.GroupLayout(jDialogNewTeam.getContentPane());
        jDialogNewTeam.getContentPane().setLayout(jDialogNewTeamLayout);
        jDialogNewTeamLayout.setHorizontalGroup(
            jDialogNewTeamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialogNewTeamLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(addTeamField, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonAddTeam, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jDialogNewTeamLayout.setVerticalGroup(
            jDialogNewTeamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialogNewTeamLayout.createSequentialGroup()
                .addContainerGap(37, Short.MAX_VALUE)
                .addGroup(jDialogNewTeamLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addTeamField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonAddTeam))
                .addContainerGap())
        );

        fco.setDialogTitle("Open");
        fco.setApproveButtonText("Open");

        newDraftDialog.setMinimumSize(new java.awt.Dimension(617, 392));
        newDraftDialog.setModal(true);

        jLabel8.setFont(new java.awt.Font("Ubuntu", 2, 16)); // NOI18N
        jLabel8.setText("Select .csv files containing data for each position");

        pitchText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pitchTextActionPerformed(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jLabel6.setText("S. Stop");

        jLabel7.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jLabel7.setText("Outfield");

        pitchBrowse.setText("Browse");
        pitchBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pitchBrowseActionPerformed(evt);
            }
        });

        createNewDraftButton.setText("Create");
        createNewDraftButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        createNewDraftButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                createNewDraftButtonActionPerformed(evt);
            }
        });

        cancelNewDraftButton.setText("Cancel");
        cancelNewDraftButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelNewDraftButtonActionPerformed(evt);
            }
        });

        addTeamNewDraftButton.setText("+");
        addTeamNewDraftButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTeamNewDraftButtonActionPerformed(evt);
            }
        });

        removeTeamNewDraftButton.setText("-");
        removeTeamNewDraftButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeTeamNewDraftButtonActionPerformed(evt);
            }
        });

        ofBrowse.setText("Browse");
        ofBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ofBrowseActionPerformed(evt);
            }
        });

        ssBrowse.setText("Browse");
        ssBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ssBrowseActionPerformed(evt);
            }
        });

        firstBrowse.setText("Browse");
        firstBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                firstBrowseActionPerformed(evt);
            }
        });

        catchBrowse.setText("Browse");
        catchBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                catchBrowseActionPerformed(evt);
            }
        });

        thirdBrowse.setText("Browse");
        thirdBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                thirdBrowseActionPerformed(evt);
            }
        });

        secondBrowse.setText("Browse");
        secondBrowse.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                secondBrowseActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jLabel1.setText("Pitcher");

        jLabel2.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jLabel2.setText("Catcher");

        jLabel3.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jLabel3.setText("1st Base");

        jLabel5.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jLabel5.setText("3rd Base");

        jLabel4.setFont(new java.awt.Font("Ubuntu", 0, 16)); // NOI18N
        jLabel4.setText("2nd Base");

        addTeamsList.setModel(addTeamsListModel);
        jScrollPane7.setViewportView(addTeamsList);

        jLabel9.setFont(new java.awt.Font("Ubuntu", 2, 16)); // NOI18N
        jLabel9.setText("Add Teams");

        addTeamText.setText("team name");

        javax.swing.GroupLayout newDraftDialogLayout = new javax.swing.GroupLayout(newDraftDialog.getContentPane());
        newDraftDialog.getContentPane().setLayout(newDraftDialogLayout);
        newDraftDialogLayout.setHorizontalGroup(
            newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newDraftDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addGroup(newDraftDialogLayout.createSequentialGroup()
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel7))
                        .addGap(29, 29, 29)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(shortText, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                            .addComponent(thirdText, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(secondText, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(firstText, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(catchText, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pitchText, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ofText))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pitchBrowse)
                            .addComponent(catchBrowse)
                            .addComponent(firstBrowse)
                            .addComponent(secondBrowse)
                            .addComponent(thirdBrowse)
                            .addComponent(ssBrowse)
                            .addComponent(ofBrowse))))
                .addGap(18, 18, 18)
                .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(addTeamText, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(newDraftDialogLayout.createSequentialGroup()
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addGroup(newDraftDialogLayout.createSequentialGroup()
                                .addComponent(addTeamNewDraftButton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(removeTeamNewDraftButton, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                                .addComponent(cancelNewDraftButton)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(createNewDraftButton)))
                .addContainerGap())
        );
        newDraftDialogLayout.setVerticalGroup(
            newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(newDraftDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9))
                .addGap(18, 18, 18)
                .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(newDraftDialogLayout.createSequentialGroup()
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(pitchText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pitchBrowse)
                            .addComponent(jLabel1))
                        .addGap(18, 18, 18)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(catchText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(catchBrowse)
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(firstText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(firstBrowse))
                        .addGap(18, 18, 18)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(secondText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(secondBrowse))
                        .addGap(18, 18, 18)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(thirdText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(thirdBrowse))
                        .addGap(18, 18, 18)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(shortText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ssBrowse))
                        .addGap(18, 18, 18)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(ofText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ofBrowse)
                            .addComponent(addTeamNewDraftButton)
                            .addComponent(removeTeamNewDraftButton))
                        .addGap(0, 31, Short.MAX_VALUE))
                    .addGroup(newDraftDialogLayout.createSequentialGroup()
                        .addComponent(jScrollPane7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(addTeamText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22)
                        .addGroup(newDraftDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cancelNewDraftButton)
                            .addComponent(createNewDraftButton))
                        .addContainerGap())))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);

        hitterTable.setModel(ht);
        hitterTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        TableColumn c = hitterTable.getColumnModel().getColumn(Hitter.NAME);
        c.setPreferredWidth(175);
        jScrollPane1.setViewportView(hitterTable);
        hitterTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        pitcherTable.setFont(pitcherTable.getFont());
        pitcherTable.setModel(pt);
        pitcherTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        TableColumn cp = pitcherTable.getColumnModel().getColumn(Pitcher.NAME);
        cp.setPreferredWidth(175);
        jScrollPane2.setViewportView(pitcherTable);
        pitcherTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        jLabel10.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
        jLabel10.setText("Free Agent Hitters");

        jLabel11.setFont(new java.awt.Font("Ubuntu", 1, 18)); // NOI18N
        jLabel11.setText("Free Agent Pitchers");

        cBoxC.setSelected(true);
        cBoxC.setText("C");
        cBoxC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cBoxCActionPerformed(evt);
            }
        });

        cBox1.setSelected(true);
        cBox1.setText("1B");
        cBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cBox1ActionPerformed(evt);
            }
        });

        cBox2.setSelected(true);
        cBox2.setText("2B");
        cBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cBox2ActionPerformed(evt);
            }
        });

        cBox3.setSelected(true);
        cBox3.setText("3B");
        cBox3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cBox3ActionPerformed(evt);
            }
        });

        cBoxS.setSelected(true);
        cBoxS.setText("SS");
        cBoxS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cBoxSActionPerformed(evt);
            }
        });

        cBoxOF.setSelected(true);
        cBoxOF.setText("OF");
        cBoxOF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cBoxOFActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 571, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addGap(18, 18, 18)
                        .addComponent(cBoxC)
                        .addGap(18, 18, 18)
                        .addComponent(cBox1)
                        .addGap(18, 18, 18)
                        .addComponent(cBox2)
                        .addGap(18, 18, 18)
                        .addComponent(cBox3)
                        .addGap(18, 18, 18)
                        .addComponent(cBoxS)
                        .addGap(18, 18, 18)
                        .addComponent(cBoxOF)))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(cBoxC)
                    .addComponent(cBox1)
                    .addComponent(cBox2)
                    .addComponent(cBox3)
                    .addComponent(cBoxS)
                    .addComponent(cBoxOF))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );

        jSplitPane1.setLeftComponent(jPanel2);

        teamTable.setModel(tt);
        teamTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        TableColumn ct = teamTable.getColumnModel().getColumn(Team.NAME);
        ct.setPreferredWidth(175);
        jScrollPane3.setViewportView(teamTable);

        teamHitterTable.setModel(tht);
        teamHitterTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        TableColumn cth = teamHitterTable.getColumnModel().getColumn(Hitter.NAME);
        cth.setPreferredWidth(150);
        jScrollPane4.setViewportView(teamHitterTable);

        teamPitcherTable.setModel(tpt);
        TableColumn ctp = teamPitcherTable.getColumnModel().getColumn(Pitcher.NAME);
        ctp.setPreferredWidth(150);
        jScrollPane5.setViewportView(teamPitcherTable);

        draftPitcherButton.setText("Draft Pitcher");
        draftPitcherButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                draftPitcherButtonActionPerformed(evt);
            }
        });

        draftHitterButton.setText("Draft Hitter");
        draftHitterButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                draftHitterButtonActionPerformed(evt);
            }
        });

        undraftHitterButton.setText("Undraft Hitter");
        undraftHitterButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                undraftHitterButtonActionPerformed(evt);
            }
        });

        undraftPitcherButton.setText("Undraft Pitcher");
        undraftPitcherButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                undraftPitcherButtonActionPerformed(evt);
            }
        });

        addTeamButton.setText("Add Team");
        addTeamButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTeamButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(addTeamButton, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                        .addGap(59, 59, 59)
                        .addComponent(draftHitterButton, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(undraftHitterButton, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(draftPitcherButton, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(undraftPitcherButton, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))
                    .addComponent(jScrollPane3))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(draftPitcherButton)
                    .addComponent(draftHitterButton)
                    .addComponent(undraftHitterButton)
                    .addComponent(undraftPitcherButton)
                    .addComponent(addTeamButton)))
            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
        );

        jSplitPane1.setRightComponent(jPanel1);

        jMenu2.setText("Menu");

        newDraftMI.setText("new draft");
        newDraftMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newDraftMIActionPerformed(evt);
            }
        });
        jMenu2.add(newDraftMI);

        newTeamMI.setText("new team");
        newTeamMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newTeamMIActionPerformed(evt);
            }
        });
        jMenu2.add(newTeamMI);

        openMI.setText("open existing draft");
        openMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openMIActionPerformed(evt);
            }
        });
        jMenu2.add(openMI);

        saveMI.setText("save draft");
        saveMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveMIActionPerformed(evt);
            }
        });
        jMenu2.add(saveMI);

        exitMI.setText("Exit");
        exitMI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMIActionPerformed(evt);
            }
        });
        jMenu2.add(exitMI);

        jMenuBar2.add(jMenu2);

        setJMenuBar(jMenuBar2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSplitPane1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSplitPane1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void setAutoCreateRowSorter(boolean autoCreateRowSorter) {
        //hitterTable.setAutoCreateRowSorter(autoCreateRowSorter);
    }

    private void newTeamMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newTeamMIActionPerformed
        // TODO add your handling code here:
        jDialogNewTeam.setVisible(true);
    }//GEN-LAST:event_newTeamMIActionPerformed

    private void jButtonAddTeamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddTeamActionPerformed
        try {
            String teamName = addTeamField.getText();
            System.out.println(teamName);
            if (!draft.teamExists(teamName)) {
                draft.addTeam(teamName);
                tt.fireTableDataChanged();
                jDialogNewTeam.setVisible(false);
                
            } else {
                System.out.println("Team Name already in use");
                // pop up "team name already in use"
            }
        } catch (NullPointerException e) {
            // pop up "team name cannot be blank"
        }
        
        
            // TODO add your handling code here:
    }//GEN-LAST:event_jButtonAddTeamActionPerformed

    private void draftHitterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_draftHitterButtonActionPerformed
        // TODO add your handling code here:
        // add selected hitter to selected team
        int selHitter = hitterTable.getSelectedRow();
                
        int selTeam = teamTable.getSelectedRow();
                
        if (selHitter == -1 || selTeam == -1) { // if no rows selected
            // open dialogue box to display error
            
            
        } else { // otherwise draft player and update tables
            draft.draftHitter(hitterTable.convertRowIndexToModel(selHitter),
                    teamTable.convertRowIndexToModel(selTeam));
            ht.fireTableDataChanged();
            tt.fireTableDataChanged();
            
            if (selHitter >= hitterTable.getRowCount()) {
                selHitter--;
            }
            
            hitterTable.setRowSelectionInterval(selHitter, selHitter);
            teamTable.setRowSelectionInterval(selTeam, selTeam); // keeps row in team table selected       
        }
    }//GEN-LAST:event_draftHitterButtonActionPerformed

    private void draftPitcherButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_draftPitcherButtonActionPerformed
        // TODO add your handling code here:
        // add selected pitcher to selected team
        int selPitcher = pitcherTable.getSelectedRow();
        int selTeam = teamTable.getSelectedRow();
        
        if (selPitcher == -1 || selTeam == -1) { // if no rows selected
            // open dialogue box to display error
        } else {
            draft.draftPitcher(pitcherTable.convertRowIndexToModel(selPitcher),
                    teamTable.convertRowIndexToModel(selTeam));
            pt.fireTableDataChanged();
            tt.fireTableDataChanged();
            
            if (selPitcher >= pitcherTable.getRowCount()) {
                selPitcher--;
            }
            pitcherTable.setRowSelectionInterval(selPitcher, selPitcher);
            teamTable.setRowSelectionInterval(selTeam, selTeam); // keeps row in team table selected
        }
    }//GEN-LAST:event_draftPitcherButtonActionPerformed

    private void undraftHitterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_undraftHitterButtonActionPerformed
        // TODO add your handling code here:
        int selHitter = teamHitterTable.getSelectedRow();
        int selTeam = teamTable.getSelectedRow();
        
        if (selHitter == -1 || selTeam == -1) {
            // error
        } else {
            draft.undraftHitter(teamHitterTable.convertRowIndexToModel(selHitter),
                    teamTable.convertRowIndexToModel(selTeam));
            tht.fireTableDataChanged();
            tt.fireTableDataChanged();
            ht.fireTableDataChanged();
            teamTable.setRowSelectionInterval(selTeam, selTeam);
            try {
                teamHitterTable.setRowSelectionInterval(selHitter, selHitter);
            } catch (IllegalArgumentException e) {
                // do nothing
            }
        }
    }//GEN-LAST:event_undraftHitterButtonActionPerformed

    private void undraftPitcherButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_undraftPitcherButtonActionPerformed
        // TODO add your handling code here:
        int selPitcher = teamPitcherTable.getSelectedRow();
        int selTeam = teamTable.getSelectedRow();
        
        if (selPitcher == -1 || selTeam == -1) {
            // error
        } else {
            draft.undraftPitcher(teamPitcherTable.convertRowIndexToModel(selPitcher),
                    teamTable.convertRowIndexToModel(selTeam));
            tpt.fireTableDataChanged();
            tt.fireTableDataChanged();
            pt.fireTableDataChanged();
            teamTable.setRowSelectionInterval(selTeam, selTeam);
            try {
                teamPitcherTable.setRowSelectionInterval(selPitcher, selPitcher);
            } catch (IllegalArgumentException e) {
                // do nothing
            }
        }
        
        
    }//GEN-LAST:event_undraftPitcherButtonActionPerformed

    private void addTeamButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addTeamButtonActionPerformed
        // TODO add your handling code here:
        jDialogNewTeam.setVisible(true);
    }//GEN-LAST:event_addTeamButtonActionPerformed

    private void saveMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMIActionPerformed
        try {
            int returnVal = fcs.showOpenDialog(DraftMateUI.this);
            
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fcs.getSelectedFile();
                draft.saveDraft(file);
            }
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(DraftMateUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException fnf) {
            fnf.printStackTrace();
        }
    }//GEN-LAST:event_saveMIActionPerformed

    private void openMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMIActionPerformed
        // TODO add your handling code here:
        int returnVal = fco.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fco.getSelectedFile();
            draft.openDraft(file);
            tt.fireTableDataChanged();
            ht.fireTableDataChanged();
            pt.fireTableDataChanged();
            tht.fireTableDataChanged();
            tpt.fireTableDataChanged();
        }
    }//GEN-LAST:event_openMIActionPerformed

    private void catchBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_catchBrowseActionPerformed
        // TODO add your handling code here:
        int returnVal = fcNew.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcNew.getSelectedFile();
            
            catchText.setText(file.toString());
        }
        
    }//GEN-LAST:event_catchBrowseActionPerformed

    private void pitchBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pitchBrowseActionPerformed
        // TODO add your handling code here:
        int returnVal = fcNew.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcNew.getSelectedFile();
            pitchText.setText(file.toString());
        }
    }//GEN-LAST:event_pitchBrowseActionPerformed

    private void newDraftMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newDraftMIActionPerformed
        // TODO add your handling code here:
        newDraftDialog.setVisible(true);
    }//GEN-LAST:event_newDraftMIActionPerformed

    private void firstBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_firstBrowseActionPerformed
        // TODO add your handling code here:
        int returnVal = fcNew.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcNew.getSelectedFile();
            firstText.setText(file.toString());
        }
    }//GEN-LAST:event_firstBrowseActionPerformed

    private void secondBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_secondBrowseActionPerformed
        // TODO add your handling code here:
        int returnVal = fcNew.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcNew.getSelectedFile();
            secondText.setText(file.toString());
        }
    }//GEN-LAST:event_secondBrowseActionPerformed

    private void thirdBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_thirdBrowseActionPerformed
        // TODO add your handling code here:
        int returnVal = fcNew.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcNew.getSelectedFile();
            thirdText.setText(file.toString());
        }
    }//GEN-LAST:event_thirdBrowseActionPerformed

    private void ssBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ssBrowseActionPerformed
        // TODO add your handling code here:
        int returnVal = fcNew.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcNew.getSelectedFile();
            shortText.setText(file.toString());
        }
    }//GEN-LAST:event_ssBrowseActionPerformed

    private void ofBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ofBrowseActionPerformed
        // TODO add your handling code here:
        int returnVal = fcNew.showOpenDialog(DraftMateUI.this);
        
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fcNew.getSelectedFile();
            ofText.setText(file.toString());
        }
    }//GEN-LAST:event_ofBrowseActionPerformed

    private void addTeamNewDraftButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addTeamNewDraftButtonActionPerformed
        // TODO add your handling code here:
        String s = addTeamText.getText();
        
        if (s.equals("") || addTeamsListModel.contains(s)) {
            // error
            Toolkit.getDefaultToolkit().beep(); // doesn't work in ubuntu
        } else {
            addTeamsListModel.addElement(s);
            addTeamText.requestFocusInWindow();
            addTeamText.setText("");
        }
    
    }//GEN-LAST:event_addTeamNewDraftButtonActionPerformed

    private void removeTeamNewDraftButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeTeamNewDraftButtonActionPerformed
        // TODO add your handling code here:
        int index = addTeamsList.getSelectedIndex();
        
        if (index != -1) {
            addTeamsListModel.remove(index);
        }
    }//GEN-LAST:event_removeTeamNewDraftButtonActionPerformed

    private void createNewDraftButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createNewDraftButtonActionPerformed
        // TODO add your handling code here:
        
        draft.clearData();
        draft.importHitters(catchText.getText(), "C");
        draft.importHitters(firstText.getText(), "1B");
        draft.importHitters(secondText.getText(), "2B");
        draft.importHitters(thirdText.getText(), "3B");
        draft.importHitters(shortText.getText(), "SS");
        draft.importHitters(ofText.getText(), "OF");
        draft.importPitchers(pitchText.getText());
        
        for (int i = 0; i < addTeamsListModel.getSize(); i++) {
            draft.addTeam(addTeamsListModel.get(i).toString());
        }
        
        ht.fireTableDataChanged();
        pt.fireTableDataChanged();
        tt.fireTableDataChanged();
        tht.fireTableDataChanged();
        tpt.fireTableDataChanged();
        
        newDraftDialog.setVisible(false);
    }//GEN-LAST:event_createNewDraftButtonActionPerformed

    private void cancelNewDraftButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelNewDraftButtonActionPerformed
        // TODO add your handling code here:
        newDraftDialog.setVisible(false);
    }//GEN-LAST:event_cancelNewDraftButtonActionPerformed

    private void pitchTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pitchTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_pitchTextActionPerformed

    private void exitMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMIActionPerformed
        // TODO add your handling code here:
        System.exit(1);
    }//GEN-LAST:event_exitMIActionPerformed

    private void cBoxCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cBoxCActionPerformed
        // TODO add your handling code here:
        if (cBoxC.isSelected()) {
            c = true;
        } else {
            c = false;
        }
        
        newFilter();
    }//GEN-LAST:event_cBoxCActionPerformed

    private void cBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cBox1ActionPerformed
        // TODO add your handling code here:
        if (cBox1.isSelected()) {
            fb = true;
        } else {
            fb = false;
        }
        
        newFilter();
    }//GEN-LAST:event_cBox1ActionPerformed

    private void cBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cBox2ActionPerformed
        // TODO add your handling code here:
        if (cBox2.isSelected()) {
            sb = true;
        } else {
            sb = false;
        }
        
        newFilter();
    }//GEN-LAST:event_cBox2ActionPerformed

    private void cBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cBox3ActionPerformed
        // TODO add your handling code here:
        if (cBox3.isSelected()) {
            tb = true;
        } else {
            tb = false;
        }
        
        newFilter();
    }//GEN-LAST:event_cBox3ActionPerformed

    private void cBoxSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cBoxSActionPerformed
        // TODO add your handling code here:
        if (cBoxS.isSelected()) {
            ss = true;
        } else {
            ss = false;
        }
        
        newFilter();
    }//GEN-LAST:event_cBoxSActionPerformed

    private void cBoxOFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cBoxOFActionPerformed
        // TODO add your handling code here:
        if (cBoxOF.isSelected()) {
            of = true;
        } else {
            of = false;
        }
        
        newFilter();
    }//GEN-LAST:event_cBoxOFActionPerformed

    private void newFilter() {
        RowFilter<HitterTable, Integer> rf = null;
        try {
            
            rf = RowFilter.regexFilter(getRegExp(), Hitter.POS);
            /*
            rf = new RowFilter<HitterTable, Integer>() {
                public boolean include(Entry<? extends HitterTable, ? extends Integer> entry) {
                    if (entry.getStringValue(Hitter.POS).contains("OF")) {
                        return true;
                    } else {
                        System.out.println(entry.getStringValue(Hitter.POS));
                        return false;
                    }
                }
            };*/
        } catch (java.util.regex.PatternSyntaxException e) {
            System.err.println("Bad Regular Expression, YO!");
        }
        hitterSorter.setRowFilter(rf);
    }
    
    private String getRegExp() {
        String regexp = "[a"; // a is not contained in any position string
        int numBrackets = 0;  // and is therefore used as an empty regexp
        if (c) {
            regexp += "C";
            numBrackets++;
        } if (fb) {
            regexp += "1";
            numBrackets++;
        } if (sb) {
            regexp += "2";
            numBrackets++;
        } if (tb) {
            regexp += "3";
            numBrackets++;
        } if (ss) {
            regexp += "S";
            numBrackets++;
        } if (of) {
            regexp += "F";
            numBrackets++;
        }
        
        regexp += "]";
        System.out.println(regexp);
        return regexp;
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DraftMateUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DraftMateUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DraftMateUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DraftMateUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new DraftMateUI().setVisible(true);
            }
        });
    }
    
    
    /*private class TeamTableListener implements TableModelListener {
        public TeamTableListener() {
            tt.addTableModelListener(this);
        }
        public void tableChanged(TableModelEvent e) {
           
        }  
    }*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addTeamButton;
    private javax.swing.JTextField addTeamField;
    private javax.swing.JButton addTeamNewDraftButton;
    private javax.swing.JTextField addTeamText;
    private javax.swing.JList addTeamsList;
    private javax.swing.JCheckBox cBox1;
    private javax.swing.JCheckBox cBox2;
    private javax.swing.JCheckBox cBox3;
    private javax.swing.JCheckBox cBoxC;
    private javax.swing.JCheckBox cBoxOF;
    private javax.swing.JCheckBox cBoxS;
    private javax.swing.JButton cancelNewDraftButton;
    private javax.swing.JButton catchBrowse;
    private javax.swing.JTextField catchText;
    private javax.swing.JButton createNewDraftButton;
    private javax.swing.JButton draftHitterButton;
    private javax.swing.JButton draftPitcherButton;
    private javax.swing.JMenuItem exitMI;
    private javax.swing.JFileChooser fcNew;
    private javax.swing.JFileChooser fco;
    private javax.swing.JFileChooser fcs;
    private javax.swing.JButton firstBrowse;
    private javax.swing.JTextField firstText;
    private javax.swing.JTable hitterTable;
    private javax.swing.JButton jButtonAddTeam;
    private javax.swing.JDialog jDialogNewTeam;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JDialog newDraftDialog;
    private javax.swing.JMenuItem newDraftMI;
    private javax.swing.JMenuItem newTeamMI;
    private javax.swing.JButton ofBrowse;
    private javax.swing.JTextField ofText;
    private javax.swing.JMenuItem openMI;
    private javax.swing.JButton pitchBrowse;
    private javax.swing.JTextField pitchText;
    private javax.swing.JTable pitcherTable;
    private javax.swing.JButton removeTeamNewDraftButton;
    private javax.swing.JMenuItem saveMI;
    private javax.swing.JButton secondBrowse;
    private javax.swing.JTextField secondText;
    private javax.swing.JTextField shortText;
    private javax.swing.JButton ssBrowse;
    private javax.swing.JTable teamHitterTable;
    private javax.swing.JTable teamPitcherTable;
    private javax.swing.JTable teamTable;
    private javax.swing.JButton thirdBrowse;
    private javax.swing.JTextField thirdText;
    private javax.swing.JButton undraftHitterButton;
    private javax.swing.JButton undraftPitcherButton;
    // End of variables declaration//GEN-END:variables
}
